package lp.xian.materials.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import lp.xian.materials.domain.WarehousingRequisitionTable;
import lp.xian.materials.service.IWarehousingRequisitionTableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入库列表Controller
 *
 * @author ruoyi
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/Warehousingtablesystem/Warehousingtable")
public class WarehousingRequisitionTableController extends BaseController
{
    @Autowired
    private IWarehousingRequisitionTableService warehousingRequisitionTableService;

    /**
     * 查询入库列表列表
     */
    @PreAuthorize("@ss.hasPermi('Warehousingtablesystem:Warehousingtable:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarehousingRequisitionTable warehousingRequisitionTable)
    {
        startPage();
        List<WarehousingRequisitionTable> list = warehousingRequisitionTableService.selectWarehousingRequisitionTableList(warehousingRequisitionTable);
        return getDataTable(list);
    }

    /**
     * 导出入库列表列表
     */
    @PreAuthorize("@ss.hasPermi('Warehousingtablesystem:Warehousingtable:export')")
    @Log(title = "入库列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarehousingRequisitionTable warehousingRequisitionTable)
    {
        List<WarehousingRequisitionTable> list = warehousingRequisitionTableService.selectWarehousingRequisitionTableList(warehousingRequisitionTable);
        ExcelUtil<WarehousingRequisitionTable> util = new ExcelUtil<WarehousingRequisitionTable>(WarehousingRequisitionTable.class);
        util.exportExcel(response, list, "入库列表数据");
    }

    /**
     * 获取入库列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('Warehousingtablesystem:Warehousingtable:query')")
    @GetMapping(value = "/{warehousingRequisitionTableId}")
    public AjaxResult getInfo(@PathVariable("warehousingRequisitionTableId") Integer warehousingRequisitionTableId)
    {
        return success(warehousingRequisitionTableService.selectWarehousingRequisitionTableByWarehousingRequisitionTableId(warehousingRequisitionTableId));
    }

    /**
     * 新增入库列表
     */
    @PreAuthorize("@ss.hasPermi('Warehousingtablesystem:Warehousingtable:add')")
    @Log(title = "入库列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarehousingRequisitionTable warehousingRequisitionTable)
    {
        return toAjax(warehousingRequisitionTableService.insertWarehousingRequisitionTable(warehousingRequisitionTable));
    }

    /**
     * 修改入库列表
     */
    @PreAuthorize("@ss.hasPermi('Warehousingtablesystem:Warehousingtable:edit')")
    @Log(title = "入库列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarehousingRequisitionTable warehousingRequisitionTable)
    {
        return toAjax(warehousingRequisitionTableService.updateWarehousingRequisitionTable(warehousingRequisitionTable));
    }

    /**
     * 删除入库列表
     */
    @PreAuthorize("@ss.hasPermi('Warehousingtablesystem:Warehousingtable:remove')")
    @Log(title = "入库列表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{warehousingRequisitionTableIds}")
    public AjaxResult remove(@PathVariable Integer[] warehousingRequisitionTableIds)
    {
        return toAjax(warehousingRequisitionTableService.deleteWarehousingRequisitionTableByWarehousingRequisitionTableIds(warehousingRequisitionTableIds));
    }
}
